package com.example.demo;

import java.util.*;

/**
 * description: FIlterNumTest <br>
 * date: 2021/4/15 10:55 <br>
 *
 * @author: ZhangYixin <br>
 * version: 1.0 <br>
 */
public class FIlterNumTest {

    public static void main(String[] args) {
        int[] nums = {1,2,10,4,1,4,3,3,6,5};
        ArrayList<Integer> singleNumbers = singleNumbers(nums);
        System.out.println(singleNumbers);

    }

    public static ArrayList<Integer> singleNumbers(int[] nums){
        Map<Integer,Integer> map = new HashMap<>(16);
        for (int num : nums) {
            map.put(num,map.getOrDefault(num,0)+1);
        }
        int index = 0;
        ArrayList<Integer> ints = new ArrayList<Integer>();
        for (int i = 0; i < nums.length; i++) {
            if (map.get(nums[i]) == 1){
                ints.add(nums[i]);
            }
        }
        return ints;
    }

}
